﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ToeplitzMatrix
{
    class Program
    {
        static bool isToeplitzMatrix(int[][] m)
        {
            if (m.Length == 0)
            {
                return true;
            }
            for(int i = 0; i < m[0].Length; i++)
            {
                for(int j = 1;i+ j < m[0].Length&&j<m.Length; j++)
                {
                    if (m[0][i] != m[j][i + j])
                        return false;
                }
            }
            for(int i = 0; i < m.Length; i++)
            {
                for(int j = 1; i + j < m.Length&&j<m[0].Length; j++)
                {
                    if (m[i][0] != m[i + j][j])
                        return false;
                }
            }
            return true;
        }
        static void Main(string[] args)
        {
            int[][] matrix = new int[3][] { new int[] { 1,2,3,4},new int[] {5,1,2,3 },new int[] {9,5,1,2 } };
            Console.WriteLine(isToeplitzMatrix(matrix));
            Console.ReadKey();
        }
    }
}
